package com.faithbj.common.model.fm.property;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;

import com.faithbj.common.model.BaseEntity;
import com.faithbj.common.model.dto.Bond;
import com.faithbj.common.model.dto.BusinessInsurance;
import com.faithbj.common.model.dto.Car;
import com.faithbj.common.model.dto.Deposit;
import com.faithbj.common.model.dto.Fund;
import com.faithbj.common.model.dto.Futures;
import com.faithbj.common.model.dto.House;
import com.faithbj.common.model.dto.Stock;
import com.faithbj.common.utils.JsonUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Lists;

/**
 * 家庭成员财产申报表
 * 所以财产信息，多于1条财产信息的，从getXXList方法返回
 * 
 * @author yfxue
 * 
 */
@Entity
@Table(name = "FM_PROPERTY_REPORT")
@JsonIgnoreProperties({"carList","houseList","depositList","stockList","fundList","businessInsuranceList","bondList","futuresList"})   
public class FamilyMemberProperty extends BaseEntity {

	private static final long serialVersionUID = 659183741133778685L;
	/**
	 *  关联的核对总体情况表ID
	 */
	private String ctId;
	/**
	 *  关联的家庭成员ID
	 */
	private String fmId;
	
//车辆Cars的list的json的stinrg
	private String cars;
//房产House的list的json的stinrg
	private String houseProperty;
//存款Deposit的list的json的stinrg
	private String deposits;
//股票Stocks的list的json的stinrg
	private String stocks;
//基金Fund的list的json的stinrg
	private String funds;
//商业保险BusinessInsurance的list的json的stinrg
	private String businessInsurance;
//债券Bonds的list的json的stinrg
	private String bonds;
//期货Futures的list的json的stinrg
	private String futures;
	
//************	
	@Column(name = "ctId", nullable = true)
	public String getCtId() {
		return ctId;
	}
	@Column(name = "fmId", nullable = false)
	public String getFmId() {
		return fmId;
	}
	@Column(name = "cars", nullable = true,length=65535)
	public String getCars() {
		return cars;
	}
	@Column(name = "house_property", nullable = true,length=65535)
	public String getHouseProperty() {
		return houseProperty;
	}
	@Column(name = "deposits", nullable = true,length=65535)
	public String getDeposits() {
		return deposits;
	}
	@Column(name = "stocks", nullable = true,length=65535)
	public String getStocks() {
		return stocks;
	}
	@Column(name = "funds", nullable = true,length=65535)
	public String getFunds() {
		return funds;
	}
	@Column(name = "business_insurance", nullable = true,length=65535)
	public String getBusinessInsurance() {
		return businessInsurance;
	}
	@Column(name = "bonds", nullable = true,length=65535)
	public String getBonds() {
		return bonds;
	}
	@Column(name = "futures", nullable = true,length=65535)
	public String getFutures() {
		return futures;
	}
//************		
	public void setCtId(String ctId) {
		this.ctId = ctId;
	}
	public void setFmId(String fmId) {
		this.fmId = fmId;
	}
	public void setCars(String cars) {
		this.cars = cars;
	}
	public void setHouseProperty(String houseProperty) {
		this.houseProperty = houseProperty;
	}
	public void setDeposits(String deposits) {
		this.deposits = deposits;
	}
	public void setStocks(String stocks) {
		this.stocks = stocks;
	}
	public void setFunds(String funds) {
		this.funds = funds;
	}
	public void setBusinessInsurance(String businessInsurance) {
		this.businessInsurance = businessInsurance;
	}
	public void setBonds(String bonds) {
		this.bonds = bonds;
	}
	public void setFutures(String futures) {
		this.futures = futures;
	}
/***********************/	
	/**
	 * 获取车辆Cars的list
	 * @return List<Car>
	 */
	@Transient
	public List<Car> getCarList() {
		if (StringUtils.isNotBlank(cars)) {
			List<Car> list = Lists.newArrayList();
			list = JsonUtil.Json2List(cars,new TypeReference<List<Car>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 房产House的list
	 * @return List<House>
	 */
	@Transient
	public List<House> getHouseList() {
		if (StringUtils.isNotBlank(houseProperty)) {
			List<House> list = Lists.newArrayList();
			list = JsonUtil.Json2List(houseProperty,new TypeReference<List<House>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 存款Deposit的list
	 * @return List<Deposit>
	 */
	@Transient
	public List<Deposit> getDepositList() {
		if (StringUtils.isNotBlank(deposits)) {
			List<Deposit> list = Lists.newArrayList();
			list = JsonUtil.Json2List(deposits,new TypeReference<List<Deposit>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 股票Stocks的list
	 * @return List<Stock>
	 */
	@Transient
	public List<Stock> getStockList() {
		if (StringUtils.isNotBlank(this.stocks)) {
			List<Stock> list = Lists.newArrayList();
			list = JsonUtil.Json2List(this.stocks,new TypeReference<List<Stock>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 基金Fund的list
	 * @return List<Fund>
	 */
	@Transient
	public List<Fund> getFundList() {
		if (StringUtils.isNotBlank(this.funds)) {
			List<Fund> list = Lists.newArrayList();
			list = JsonUtil.Json2List(this.funds,new TypeReference<List<Fund>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 商业保险BusinessInsurance的list
	 * @return
	 */
	@Transient
	public List<BusinessInsurance> getBusinessInsuranceList() {
		if (StringUtils.isNotBlank(this.businessInsurance)) {
			List<BusinessInsurance> list = Lists.newArrayList();
			list = JsonUtil.Json2List(this.businessInsurance,new TypeReference<List<BusinessInsurance>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 债券Bond的list
	 * @return
	 */
	@Transient
	public List<Bond> getBondList() {
		if (StringUtils.isNotBlank(this.bonds)) {
			List<Bond> list = Lists.newArrayList();
			list = JsonUtil.Json2List(this.bonds,new TypeReference<List<Bond>>() {});
			return list;
		}
		return null;
	}
	/**
	 * 期货Futures的list
	 * @return List<Futures>
	 */
	@Transient
	public List<Futures> getFuturesList() {
		if (StringUtils.isNotBlank(this.futures)) {
			List<Futures> list = Lists.newArrayList();
			list = JsonUtil.Json2List(this.futures,new TypeReference<List<Futures>>() {});
			return list;
		}
		return null;
	}
	

	/**
	 * 车辆Cars的list的json的stinrg
	 */
	@Transient
	public void setCarList(List<Car> carList) {
		if (carList != null && carList.size() >= 0) {
			cars=JsonUtil.toJson(carList);
		}
	}
	@Transient
	public void setHouseList(List<House> houseList) {
		if (houseList != null && houseList.size() >= 0) {
			houseProperty=JsonUtil.toJson(houseList);
		}
	}
	@Transient
	public void setDepositList(List<Deposit> depositList) {
		if (depositList != null && depositList.size() >= 0) {
			this.deposits=JsonUtil.toJson(depositList);
		}
	}
	@Transient
	public void setStockList(List<Stock> stockList) {
		if (stockList != null && stockList.size() >= 0) {
			this.stocks=JsonUtil.toJson(stockList);
		}
	}
	/**
	 * 基金Fund的list的json的stinrg
	 * @param fundList
	 */
	@Transient
	public void setFundList(List<Fund> fundList) {
		if (fundList != null && fundList.size() >= 0) {
			this.funds=JsonUtil.toJson(fundList);
		}
	}	
	@Transient
	public void setBusinessInsuranceList(
			List<BusinessInsurance> businessInsuranceList) {
		if (businessInsuranceList != null && businessInsuranceList.size() >= 0) {
			this.businessInsurance=JsonUtil.toJson(businessInsuranceList);
		}
	}	
	/**
	 * 债券Bond的list的json的stinrg
	 * @return
	 */
	@Transient
	public void setBondList(List<Bond> bondList) {
		if (bondList != null && bondList.size() >= 0) {
			this.bonds=JsonUtil.toJson(bondList);
		}
	}	
	/**
	 * 期货Futures的list的json的stinrg
	 * @return List<Futures>
	 */
	@Transient
	public void setFuturesList(List<Futures> futuresList) {
		if (futuresList != null && futuresList.size() >= 0) {
			this.futures=JsonUtil.toJson(futuresList);
		}
	}	

}
